import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import refresh from '@dfeidao/atom-web/url/refresh';

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const nos = get(fd, 'nos');
	const arr1 = get(fd, 'arr') as Array<{ plan_item_no: string }>;
	let arr = arr1.map((v) => {
		if (v.plan_item_no) {
			const n = v.plan_item_no;
			return n
		}
	})
	let newArr: string[] = [];
	arr.forEach(item => {
		if (item) {
			newArr.push(item)
		}
	})
	console.log("计划清单编号", nos);

	console.log('计划项目编号', newArr);
	const res = await nodejs<{ code: 0 | 1; result: string; }>('wangju/zj-000007/s002', {
		arr: nos,


	});
	console.log(res);
	if (newArr) {
		const res = await nodejs('wangju/zj-000007/s003', {
			arr: newArr,
		});
		console.log(res);
	}
	if (res.code === 1) {
		alert('删除成功');
		refresh();
	} else {
		alert('删除失败');
	}
}
